﻿using System;
using System.Collections.Generic;
using System.Text;
using Model;
using System.Xml.Serialization;
using System.IO;
using System.Windows.Forms;


namespace Controller
{
	static class WriteReadDataAsXML
	{
		#region Member

		static List<ClipElement> m_logList = new List<ClipElement>();

		public static List<ClipElement> LogList1
		{
			get { return WriteReadDataAsXML.m_logList; }
			set { WriteReadDataAsXML.m_logList = value; }
		}
		
		static public string m_xmlFileLocation = Path.Combine(Application.StartupPath, "logFile.xml");

		#endregion

		#region Properties

		static public List<ClipElement> LogList
		{
			get { return WriteReadDataAsXML.m_logList; }
			set { WriteReadDataAsXML.m_logList = value; }
		}

		#endregion


		#region Methods

		public static void writeDataInXML()
		{
			// Delete the Current XML-File
			File.WriteAllText(m_xmlFileLocation, string.Empty);

			foreach(ClipElement listElement in m_logList)
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClipElement));
	
				TextWriter txtWriter = new StreamWriter(m_xmlFileLocation);

				xmlSerializer.Serialize(txtWriter, listElement);
			}
		}

		#endregion
	}
}
